﻿namespace GuiaTest
{
    using System;
    using Guia.Core;
    using Guia.Elements;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using WpfTestApplication;

    /// <summary>
    /// Summary description for ButtonTest
    /// </summary>
    [TestClass]
    public class TextBoxTest : AbstractWindowTest
    {
        protected override Type TestWindowType()
        {
            return typeof(TextBoxTestWindow);
        }

        protected override string TestWindowName()
        {
            return "TextBoxTestWindow";
        }

        [TestMethod]
        public void TestTextBoxValue()
        {
            Assert.IsNotNull(window);
            TextBox txtText = window.Get<TextBox>("txtText");
            Assert.AreEqual("", txtText.Value);
            // Enter value
            txtText.Value = "Hello";
            Assert.AreEqual("Hello", txtText.Value);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestSetTextBoxValueNullValue()
        {
            Assert.IsNotNull(window);
            TextBox txtText = window.Get<TextBox>("txtText");
            txtText.Value = null;
        }

        [TestMethod,ExpectedException(typeof(OperationNotSupportedException))]
        public void TestTextBoxValueReadOnly()
        {
            TextBox textBox = window.Get<TextBox>("txtReadOnly");
            textBox.Value = "new value";
        }

        [TestMethod]
        public void TestIsReadOnly()
        {
            TextBox txtText = window.Get<TextBox>("txtText");
            TextBox txtReadOnly = window.Get<TextBox>("txtReadOnly");
            Assert.IsFalse(txtText.IsReadOnly);
            Assert.IsTrue(txtReadOnly.IsReadOnly);
        }
    }
}
